<html xmlns:th="http://www.thymeleaf.org" lang="ru">
<head>
    <title>CRUD</title>
    <div th:replace="fragments/header :: header-css"></div>
</head>
<body>
<div th:replace="fragments/header :: header"></div>
<div class="container-xl ml-3 mr-3">
    <div class="row">
        <div class="col m-3">
            <main>
                <div class="row" th:include="fragments/editEntity :: edit-form"
                     th:if="${param.id!=null}" id="editEntity"></div>
                <div class="row mt-3">
                    <a class="form-control btn btn-primary btn-block" id="submit"
                       th:href="@{/entities?id=&entityClass={class}(class=${#httpServletRequest.getParameter('entityClass')})}">New
                        entity</a>
                </div>
                <div class="row mt-3" th:include="fragments/entitiesList :: entities-list" id="entities-list"></div>
            </main>
        </div>
        <div class="col-md-auto m-3">
            <div>
                <button class="btn btn-primary" type="button" value="Администратор модели" id="admin-mode"
                        onclick="document.getElementById('editor').style.display=document.getElementById('editor').style.display === 'none' ? 'block' : 'none';">
                    Администратор модели
                </button>
            </div>
            <div id="editor" th:text="${code}" style="display: none" class="mt-3 border">
            </div>
        </div>
    </div>
</div>
<div th:replace="fragments/footer :: footer"/>

<script src="ace-builds/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="ace-builds/src-min-noconflict/theme-dracula.js" type="text/javascript" charset="utf-8"></script>
<script src="ace-builds/src-min-noconflict/mode-java.js" type="text/javascript" charset="utf-8"></script>
<script>
    let editor = ace.edit("editor");
    editor.setTheme("ace/theme/chrome");
    let JavaMode = ace.require("ace/mode/java").Mode;
    editor.session.setMode(new JavaMode());
</script>
</body>
</html>